package dao;

public class Pagination {
    //返回limit字句
    public String toLimitClause(int totalNum){
        //向前台提供元组总数
        this.totalNum = totalNum;
        //偏移量
        int offset = (this.pageNo-1)*pageSize;
        //输出limit字句
        return " LIMIT " + offset + "," + this.pageSize;
    }
    public Pagination(int pageSize,int pageNo){
        if (pageNo > 0){ //防止错误赋值
            this.pageNo = pageNo;
        }

        if (pageSize > 0){
            this.pageSize = pageSize;
        }
    }
    //如果没有get方法，fastjson将无法读取对象属性
    public int getPageSize() {
        return pageSize;
    }
    public int getPageNo() {
        return pageNo;
    }
    public int getTotalNum() {
        return totalNum;
    }
    private int pageSize = 5;//每页的对象数
    private int pageNo = 1;//页号
    private int totalNum = 1;//对象总数
}
